package no.uials.distsys;

import java.awt.*;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.security.Permission;

/**
 *
 * @author Anders & Martinsen
 */
public class Client {

    public final Dimension D = Toolkit.getDefaultToolkit().getScreenSize();

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        new Client();
    }

    public Client() {
        System.out.println("Client starting...");
        
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager() {
                @Override
                public void checkConnect(String host, int port) {}
                @Override
                public void checkConnect(String host, int port, Object obj) {}
                @Override
                public void checkAccept(String host, int port) {}
                @Override
                public void checkPermission(Permission perm) {}
            });
        }
        DistSysService service = null;
        try {
            //*Find default RMI-registry*//
            service = (DistSysService) Naming.lookup("rmi://127.0.0.1/"
                    + DistSysService.class.getName());
        } catch (NotBoundException | MalformedURLException | RemoteException ex) {
            ex.printStackTrace();
        }
        try {
            new Login(service, this).setVisible(true);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}